package com.ly.gateway.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class GateWayConfig {


    /**
     * @describe：启动服务后，可以通过终端或者Postman等工具调用 http://localhost:8889/user
     * 会发现请求被路由转发到http://localhost:8888/user
     * @author：李勇
     * @date：2022/6/27 
     * @param builder
     * @return：org.springframework.cloud.gateway.route.RouteLocator
     */       
//    @Bean
    public RouteLocator routeLocator (RouteLocatorBuilder builder){
        return builder.routes()
                //配置路由
                //id 服务名
                //path 该服务下映射的方法
                .route("consumer", r -> r.path("/consumer/test")
                        .uri("http://localhost:9001"))
                .build();
    }



}
